package com.hspedu.extend_;
/*
讲解继承的本质
 */
public class ExtendsTheory {
    public static void main(String[] args) {
        Son son = new Son();
        System.out.println(son.name);
//        System.out.println(son.age);//错误 : 即使爷爷类有变量age,但是father类里已经有了一个private的age，在son里调用的时候，只要上继承中找到了一个age就停下来了，不会再继续找/**/
        System.out.println(son.getAge());
        System.out.println(son.hobby);
    }
}


class GrandPa{
    String name = "大头爷爷";
    String hobby = "旅游";
    int age = 120;
}
class Father extends GrandPa{
    String name = "大头爸爸";
    private int age = 39;

    public int getAge() {
        return age;
    }
}
class Son extends Father{
    String name = "大头儿子";
}